//
//  InformationHeadView.m
//  meiyinxiang
//
//  Created by lizidi on 2018/1/11.
//  Copyright © 2018年 hbjApple. All rights reserved.
//

#import "InformationHeadView.h"
#import "UIImageView+LBBlurredImage.h"
#import "MYXReleaseTopView.h"


@interface InformationHeadView()
@property(nonatomic,strong)UIImageView * bgImageView;
//头像   性别
@property(nonatomic,strong)UIImageView * headView,*sexView,*zanView;
//姓名   签名  获得的赞
@property(nonatomic,strong)UILabel * nameLabel,*detialLabel,*zanLabel;
//访客   发出的红包  收到的红包
@property(nonatomic,strong) MYXReleaseTopView * fangke ,*fachu,*shoudao;


@end

@implementation InformationHeadView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        //创建视图
        [self createView];
    }
    
    return self;
}
-(void)createView{
    
    //    if (!_bgImageView) {
    //        _bgImageView = [[UIImageView alloc]init];
    //        _bgImageView.image = [UIImage imageNamed:@"board_first"];
    //        [_bgImageView setImageToBlur:_bgImageView.image blurRadius:5 completionBlock:nil];
    //        [self addSubview:_bgImageView];
    //        [_bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
    //            make.top.left.offset(0);
    //            make.height.offset([MyAdapter laDapter:220]);
    //            make.width.offset(ScreenWidth);
    //        }];
    //    }
    if (!_headView) {
        _headView = [[UIImageView alloc]init];
//        _headView.image = [UIImage imageNamed:@"board_first"];
        [_headView.layer setCornerRadius:[MyAdapter laDapter:71]/2];
        _headView.layer.masksToBounds = YES;
        [self addSubview:_headView];
        [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset([MyAdapter laDapter:15]);
            make.top.offset([MyAdapter laDapter:65]);
            make.width.height.offset([MyAdapter laDapter:71]);
        }];
    }
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.textColor = [UIColor whiteColor];
        _nameLabel.font = [MyAdapter lfontADapter:17];
        [self addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_headView.mas_top);
            make.height.offset([MyAdapter laDapter:17]);
            make.left.equalTo(_headView.mas_right).offset([MyAdapter laDapter:10]);
        }];
    }
    if (!_detialLabel) {
        _detialLabel = [[UILabel alloc]init];
        _detialLabel.textColor = [UIColor whiteColor];
        _detialLabel.font = [MyAdapter lfontADapter:13];
        [self addSubview:_detialLabel];
        [_detialLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_nameLabel.mas_bottom).offset([MyAdapter laDapter:15]);
            make.height.offset([MyAdapter laDapter:13]);
            make.left.equalTo(_headView.mas_right).offset([MyAdapter laDapter:10]);
        }];
    }
    if (!_sexView) {
        _sexView = [[UIImageView alloc]init];
        [self addSubview:_sexView];
        [_sexView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headView.mas_right).offset([MyAdapter laDapter:-18]);
            make.bottom.equalTo(_headView.mas_bottom).offset([MyAdapter laDapter:0]);
            make.width.height.offset([MyAdapter laDapter:16]);
        }];
    }
    if (!_zanView) {
        _zanView = [[UIImageView alloc]init];
        _zanView.image = [UIImage imageNamed:@"dz"];
        [self addSubview:_zanView];
        [_zanView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(_headView.mas_bottom);
            make.left.equalTo(_headView.mas_right).offset([MyAdapter laDapter:10]);
            make.height.width.offset([MyAdapter laDapter:13]);
        }];
    }
    if (!_zanLabel) {
        _zanLabel = [[UILabel alloc]init];
        _zanLabel.textColor = [UIColor whiteColor];
        _zanLabel.font = [MyAdapter lfontADapter:13];
        [self addSubview:_zanLabel];
        [_zanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_zanView.mas_top);
            make.height.offset([MyAdapter laDapter:13]);
            make.left.equalTo(_zanView.mas_right).offset([MyAdapter laDapter:7]);
        }];
    }
    _fangke = [[MYXReleaseTopView alloc]init];
    [self addSubview:_fangke];
    [_fangke mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset([MyAdapter laDapter:72.5]);
        make.top.equalTo(_headView.mas_bottom).offset([MyAdapter laDapter:10]);
        make.height.offset([MyAdapter laDapter:60]);
    }];
    _fachu = [[MYXReleaseTopView alloc]init];
    [self addSubview:_fachu];
    [_fachu mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_headView.mas_bottom).offset([MyAdapter laDapter:10]);
        make.height.offset([MyAdapter laDapter:60]);
        make.centerX.equalTo(self).offset([MyAdapter laDapter:-25]);
    }];
    _shoudao = [[MYXReleaseTopView alloc]init];
    [self addSubview:_shoudao];
    [_shoudao mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset([MyAdapter laDapter:-120]);
        make.top.equalTo(_headView.mas_bottom).offset([MyAdapter laDapter:10]);
        make.height.offset([MyAdapter laDapter:60]);
    }];
    
}

-(void)setOtheruserinfoModel:(MYXotheruserinfoModel *)otheruserinfoModel
{
   //头像
//    [self.headView sd_setImageWithURL:[NSURL URLWithString:otheruserinfoModel.image]placeholderImage:[UIImage imageNamed:@"AppIcon"]];
    [self.headView sd_setImageWithURL:[NSURL URLWithString:[MYXMemberMdel sharedInstance].userinfo.image] placeholderImage:[UIImage imageNamed:@"AppIcon"]];
    //昵称
    if (otheruserinfoModel.username.length<=0) {
        self.nameLabel.text = @"";
    }else{
        self.nameLabel.text = otheruserinfoModel.username;
    }
    //签名
    if (otheruserinfoModel.signature.length>0) {
        self.detialLabel.text = otheruserinfoModel.signature;
    }else{
        self.detialLabel.text = @"";
    }
    //性别
    if ([otheruserinfoModel.sex isEqualToString:@"1"]) {
        self.sexView.image = [UIImage imageNamed:@"men"];
    }else{
        self.sexView.image = [UIImage imageNamed:@"women"];
    }
    //赞数
    self.zanLabel.text = otheruserinfoModel.zancount;
    //访客  发出  收到
   
    [_fangke configDataWithTitle:@"访客" Num:otheruserinfoModel.kecount
     ];
    [_fachu configDataWithTitle:@"发出" Num:[NSString stringWithFormat:@"%@%@",@"¥",[NSString stringWithFormat:@"%.2f",[otheruserinfoModel.sendmoney floatValue]]
     ]];
    [_shoudao configDataWithTitle:@"收到" Num:[NSString stringWithFormat:@"%@%@",@"¥",[NSString stringWithFormat:@"%.2f",[otheruserinfoModel.getmoney floatValue]]]
     ];
    
}


/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end

